package com.example.demo.controller;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.example.demo.entity.MyUser;
import com.example.demo.service.MyUserService;
//my.authers=ADMIN,ROOT,WORKER,YOU
//my.autherNames=\u7BA1\u7406\u5458,\u8D85\u4EBA,\u4F5C\u8005,\u6E38\u5BA2
@Controller
@RequestMapping("re")
public class RegisteController {
	@Value("${my.authers}")
	private String authers;
	
	@Value("${my.autherNames}")
	private String autherNames;
	
	@GetMapping("view")
	public String view(Map<String, Object> map){
		map.put("authers", authers.split(","));
		map.put("autherNames",JSON.toJSONString(autherNames) );
		return "regist";
		
	}
	@Resource
	private MyUserService myUserService;
	
	@PostMapping("handler")
	@ResponseBody
	public Object rigist(MyUser myUser) {
		return myUserService.regist(myUser);
	}
}
